<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.css" integrity="sha256-6cQIC71/iBIYXFK+0RHAvwmjwWzkWd+r7v/BX3/vZDc=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/green/pace-theme-minimal.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"sumumm.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":true,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="本文主要是H264的SPS帧简介的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:type" content="article">
<meta property="og:title" content="LV05-02-H264-11-01-SPS帧简介">
<meta property="og:url" content="https://sumumm.github.io/post/8213b8b3.html">
<meta property="og:site_name" content="苏木">
<meta property="og:description" content="本文主要是H264的SPS帧简介的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241213164505373.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216150048551.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216202528199.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216150702583.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216150721839.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216203352731.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216203927607.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216203958920.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204059314.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204144271.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204221277.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204303087.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204439678.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204439678.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204439678.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204923372.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204923372.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204923372.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204923372.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216205138883.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216205232610.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216205232610.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216205232610.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216205356440.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216205425465.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217090353410.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217090951614.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217090951614.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217090951614.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217091336803.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217091442769.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217091557561.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217091557561.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217091557561.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217092002476.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217092002476.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217092002476.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217092820786.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217093104751.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217093207793.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217093607508.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217093607508.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217093607508.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217093845893.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217094157229.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217095023307.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217095023307.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217095023307.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217101222645.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217101419996.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217101535747.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217101721321.png">
<meta property="article:published_time" content="2024-12-17T15:45:38.000Z">
<meta property="article:modified_time" content="2025-06-13T16:25:57.064Z">
<meta property="article:author" content="苏木">
<meta property="article:tag" content="LV05-视频编解码">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241213164505373.png">


<link rel="canonical" href="https://sumumm.github.io/post/8213b8b3.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":"","permalink":"https://sumumm.github.io/post/8213b8b3.html","path":"post/8213b8b3.html","title":"LV05-02-H264-11-01-SPS帧简介"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>LV05-02-H264-11-01-SPS帧简介 | 苏木</title>
  








    <script src="/js/browser_tools_disable.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<!-- hexo injector head_end start --><link rel="stylesheet" href="https://unpkg.com/hexo-next-tags-plus@latest/lib/tag_plus.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">苏木</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">我的学习之路</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>苏木的家</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类页<span class="badge">42</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档页<span class="badge">673</span></a></li><li class="menu-item menu-item-flink"><a href="/flink/" rel="section"><i class="fa fa-link fa-fw"></i>友人帐</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81SPS%E5%B8%A7"><span class="nav-text">一、SPS帧</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-SPS%E6%98%AF%E4%BB%80%E4%B9%88"><span class="nav-text">1. SPS是什么</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-SPS%E5%9F%BA%E6%9C%AC%E6%A0%BC%E5%BC%8F"><span class="nav-text">2. SPS基本格式</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81SPS%E6%A0%BC%E5%BC%8F%E5%88%86%E6%9E%90"><span class="nav-text">二、SPS格式分析</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-ue-v-%E4%B8%8Ese-v"><span class="nav-text">1.ue(v)与se(v)</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E6%A0%BC%E5%BC%8F%E8%AF%B4%E6%98%8E"><span class="nav-text">2. 格式说明</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-profile-idc"><span class="nav-text">2.1 profile_idc</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-constraint-set0-5-flag"><span class="nav-text">2.2 constraint_set0~5_flag</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-3-reserved-zero-2bits"><span class="nav-text">2.3 reserved_zero_2bits</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-4-level-idc"><span class="nav-text">2.4 level_idc</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-5-seq-parameter-set-id"><span class="nav-text">2.5 seq_parameter_set_id</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81%E5%AE%9E%E4%BE%8B%E5%88%86%E6%9E%90"><span class="nav-text">三、实例分析</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-0x00-0x00-0x00-0x01"><span class="nav-text">1. 0x00,0x00,0x00,0x01</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-0x67"><span class="nav-text">2. 0x67</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E7%AC%AC5%E3%80%816%E3%80%817%E5%AD%97%E8%8A%82"><span class="nav-text">3. 第5、6、7字节</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-%E7%AC%AC8%E5%AD%97%E8%8A%82"><span class="nav-text">4. 第8字节</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-%E7%AC%AC9%E5%AD%97%E8%8A%82"><span class="nav-text">5. 第9字节</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-%E7%AC%AC9-10%E5%AD%97%E8%8A%82"><span class="nav-text">6. 第9 - 10字节</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#7-%E7%AC%AC11-14%E5%AD%97%E8%8A%82"><span class="nav-text">7. 第11 - 14字节</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#8-%E7%AC%AC14%E5%AD%97%E8%8A%82"><span class="nav-text">8. 第14字节</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#9-%E7%AC%AC14%E5%AD%97%E8%8A%82"><span class="nav-text">9. 第14字节</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#10-%E7%AC%AC14-15%E5%AD%97%E8%8A%82"><span class="nav-text">10. 第14 - 15字节</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#11-%E7%AC%AC15-24%E5%AD%97%E8%8A%82"><span class="nav-text">11. 第15 - 24字节</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#12-%E7%AC%AC25%E5%AD%97%E8%8A%82"><span class="nav-text">12. 第25字节</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#13-%E6%80%BB%E7%BB%93"><span class="nav-text">13. 总结</span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="苏木"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">苏木</p>
  <div class="site-description" itemprop="description">莫道桑榆晚，为霞尚满天</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">673</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">42</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">43</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/sumumm" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sumumm" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://sumumm.github.io/post/8213b8b3.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="苏木">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏木">
      <meta itemprop="description" content="莫道桑榆晚，为霞尚满天">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="LV05-02-H264-11-01-SPS帧简介 | 苏木">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          LV05-02-H264-11-01-SPS帧简介
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2024-12-17 23:45:38" itemprop="dateCreated datePublished" datetime="2024-12-17T23:45:38+08:00">2024-12-17</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">嵌入式开发</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/" itemprop="url" rel="index"><span itemprop="name">04音视频</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/" itemprop="url" rel="index"><span itemprop="name">LV05-视频编解码</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>8.2k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>30 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><p>本文主要是H264的SPS帧简介的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。</p>
<span id="more"></span>

<!-- Photo: https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/ -->

<details class="folding-tag" blue><summary> 点击查看使用工具及版本 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center" rowspan="5">PC端开发环境</td>        <td align="center" width=150px>Windows</td>        <td align="left">Windows11</td>    </tr>    <tr>        <td align="center">Ubuntu</td>        <td align="left">Ubuntu20.04.6的64位版本</td>      </tr>    <tr>        <td align="center">VMware® Workstation 17 Pro</td>        <td align="left">17.0.0 build-20800274</td>      </tr>    <tr>        <td align="center">终端软件</td>        <td align="left">MobaXterm(Professional Edition v23.0 Build 5042 (license))</td>    </tr>    <tr>        <td align="center">Win32DiskImager</td>        <td align="left">Win32DiskImager v1.0</td>      </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看本文参考资料 </summary>
              <div class='content'>
              <table>    <tr><td align="center">参考资料  </td><td align="center">相关链接</td></tr>    <tr><td align="left">H264文档</td><td align="left"><a href="https://gitee.com/sumumm/audio-and-video/raw/master/参考资料/T-REC-H.264-202408-I-E.pdf" target="_blank"> ITU-T Rec. H.264 (08/2024) Advanced video coding for generic audiovisual services </a></td></tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看相关文件下载 </summary>
              <div class='content'>
              <table>    <tr><td align="left"><a href="" target="_blank">---</a></td><td align="left">---</td></tr></table>
              </div>
            </details>

<h1 id="一、SPS帧"><a href="#一、SPS帧" class="headerlink" title="一、SPS帧"></a><font size=3>一、SPS帧</font></h1><h2 id="1-SPS是什么"><a href="#1-SPS是什么" class="headerlink" title="1. SPS是什么"></a><font size=3>1. SPS是什么</font></h2><p>在H.264标准协议中规定了多种不同的NAL Unit类型，其中类型7表示该NAL Unit内保存的数据为Sequence Paramater Set（SPS）。一个SPS帧的数据如下：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">uint8_t</span> data_buffer[SPS_DATA_SIZE] = &#123;<span class="number">0x00</span>,<span class="number">0x00</span>,<span class="number">0x00</span>,<span class="number">0x01</span>,<span class="number">0x67</span>,<span class="number">0x64</span>,<span class="number">0x00</span>,<span class="number">0x33</span>,<span class="number">0xac</span>,<span class="number">0x15</span>,<span class="number">0x14</span>,<span class="number">0xa0</span>,<span class="number">0x50</span>,<span class="number">0x05</span>,<span class="number">0xba</span>,<span class="number">0x68</span>,<span class="number">0x80</span>,<span class="number">0x00</span>,<span class="number">0x01</span>,<span class="number">0xf4</span>,<span class="number">0x00</span>,<span class="number">0x00</span>,<span class="number">0x75</span>,<span class="number">0x30</span>,<span class="number">0x02</span> &#125;;</span><br></pre></td></tr></table></figure>

<p>在H.264的各种语法元素中，SPS中的信息至关重要。如果其中的数据丢失或出现错误，那么解码过程很可能会失败。SPS及后续将要讲述的图像参数集PPS在某些平台的视频处理框架（比如iOS的VideoToolBox等）还通常作为解码器实例的初始化信息使用。</p>
<p><strong>SPS 即 Sequence Paramater Set，又称作序列参数集。SPS 中保存了一组编码视频序列 (Coded video sequence) 的全局参数。</strong> 所谓的编码视频序列即原始视频的一帧一帧的像素数据经过编码之后的结构组成的序列。而每一帧的编码后数据所依赖的参数保存于图像参数集中。一般情况SPS和PPS的NAL Unit通常位于整个码流的起始位置。但在某些特殊情况下，在码流中间也可能出现这两种结构，主要原因可能为：</p>
<ul>
<li>解码器需要在码流中间开始解码；</li>
<li>编码器在编码的过程中改变了码流的参数（如图像分辨率等）；</li>
</ul>
<h2 id="2-SPS基本格式"><a href="#2-SPS基本格式" class="headerlink" title="2. SPS基本格式"></a><font size=3>2. SPS基本格式</font></h2><p>H.264标准协议中规定的SPS格式位于 <a target="_blank" rel="noopener" href="https://gitee.com/sumumm/audio-and-video/raw/master/%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99/T-REC-H.264-202408-I-E.pdf">ITU-T Rec. H.264 (08&#x2F;2024) Advanced video coding for generic audiovisual services</a> 文档的7.3.2.1.1 Sequence parameter set data syntax 。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br></pre></td><td class="code"><pre><span class="line">seq_parameter_set_data()</span><br><span class="line">&#123;</span><br><span class="line">    profile_idc;                          <span class="comment">// 0 u(8)</span></span><br><span class="line">    constraint_set0_flag;                 <span class="comment">// 0 u(1)</span></span><br><span class="line">    constraint_set1_flag;                 <span class="comment">// 0 u(1)</span></span><br><span class="line">    constraint_set2_flag;                 <span class="comment">// 0 u(1)</span></span><br><span class="line">    constraint_set3_flag;                 <span class="comment">// 0 u(1)</span></span><br><span class="line">    constraint_set4_flag;                 <span class="comment">// 0 u(1)</span></span><br><span class="line">    constraint_set5_flag;                 <span class="comment">// 0 u(1)</span></span><br><span class="line">    reserved_zero_2bits; <span class="comment">/* equal to 0 */</span> <span class="comment">// 0 u(2)</span></span><br><span class="line">    level_idc;                            <span class="comment">// 0 u(8)</span></span><br><span class="line">    seq_parameter_set_id;                 <span class="comment">// 0 ue(v)</span></span><br><span class="line">    <span class="keyword">if</span> (profile_idc == <span class="number">100</span> || profile_idc == <span class="number">110</span> || </span><br><span class="line">        profile_idc == <span class="number">122</span> || profile_idc == <span class="number">244</span> || </span><br><span class="line">        profile_idc == <span class="number">44</span> || profile_idc == <span class="number">83</span> || </span><br><span class="line">        profile_idc == <span class="number">86</span> || profile_idc == <span class="number">118</span> || </span><br><span class="line">        profile_idc == <span class="number">128</span> || profile_idc == <span class="number">138</span> || </span><br><span class="line">        profile_idc == <span class="number">139</span> || profile_idc == <span class="number">134</span> || </span><br><span class="line">        profile_idc == <span class="number">135</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        chroma_format_idc;                    <span class="comment">// 0 ue(v)</span></span><br><span class="line">            <span class="keyword">if</span> (chroma_format_idc = = <span class="number">3</span>)</span><br><span class="line">                separate_colour_plane_flag;   <span class="comment">// 0 u(1)</span></span><br><span class="line">        bit_depth_luma_minus8;                <span class="comment">// 0 ue(v)</span></span><br><span class="line">        bit_depth_chroma_minus8;              <span class="comment">// 0 ue(v)</span></span><br><span class="line">        qpprime_y_zero_transform_bypass_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">        seq_scaling_matrix_present_flag;      <span class="comment">// 0 u(1)</span></span><br><span class="line">        <span class="keyword">if</span> (seq_scaling_matrix_present_flag)</span><br><span class="line">            <span class="keyword">for</span> (i = <span class="number">0</span>; i &lt; ((chroma_format_idc != <span class="number">3</span>) ? <span class="number">8</span> : <span class="number">12</span>); i++)</span><br><span class="line">            &#123;</span><br><span class="line">                seq_scaling_list_present_flag[i]; <span class="comment">// 0 u(1)</span></span><br><span class="line">                <span class="keyword">if</span> (seq_scaling_list_present_flag[i])</span><br><span class="line">                    <span class="keyword">if</span> (i &lt; <span class="number">6</span>)</span><br><span class="line">                        scaling_list(ScalingList4x4[i], <span class="number">16</span>, </span><br><span class="line">                            UseDefaultScalingMatrix4x4Flag[i]);     <span class="comment">// 0</span></span><br><span class="line">                    <span class="keyword">else</span></span><br><span class="line">                        scaling_list(ScalingList8x8[i - <span class="number">6</span>], <span class="number">64</span>, </span><br><span class="line">                            UseDefaultScalingMatrix8x8Flag[i - <span class="number">6</span>]); <span class="comment">// 0</span></span><br><span class="line">            &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    log2_max_frame_num_minus4; <span class="comment">// 0 ue(v)</span></span><br><span class="line">    pic_order_cnt_type;        <span class="comment">// 0 ue(v)</span></span><br><span class="line">    <span class="keyword">if</span> (pic_order_cnt_type == <span class="number">0</span>)</span><br><span class="line">        log2_max_pic_order_cnt_lsb_minus4; <span class="comment">// 0 ue(v)</span></span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">if</span> (pic_order_cnt_type == <span class="number">1</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        delta_pic_order_always_zero_flag;      <span class="comment">// 0 u(1)</span></span><br><span class="line">        offset_for_non_ref_pic;                <span class="comment">// 0 se(v)</span></span><br><span class="line">        offset_for_top_to_bottom_field;        <span class="comment">// 0 se(v)</span></span><br><span class="line">        num_ref_frames_in_pic_order_cnt_cycle; <span class="comment">// 0 ue(v)</span></span><br><span class="line">        <span class="keyword">for</span> (i = <span class="number">0</span>; i &lt; num_ref_frames_in_pic_order_cnt_cycle; i++)</span><br><span class="line">            offset_for_ref_frame[i];      <span class="comment">// 0 use(v)</span></span><br><span class="line">    &#125;</span><br><span class="line">    max_num_ref_frames;                   <span class="comment">// 0 ue(v)</span></span><br><span class="line">    gaps_in_frame_num_value_allowed_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    pic_width_in_mbs_minus1;              <span class="comment">// 0 ue(v)</span></span><br><span class="line">    pic_height_in_map_units_minus1;       <span class="comment">// 0 ue(v)</span></span><br><span class="line">    frame_mbs_only_flag;                  <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (!frame_mbs_only_flag)</span><br><span class="line">        mb_adaptive_frame_field_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    direct_8x8_inference_flag;        <span class="comment">// 0 u(1)</span></span><br><span class="line">    frame_cropping_flag;              <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (frame_cropping_flag)</span><br><span class="line">    &#123;</span><br><span class="line">        frame_crop_left_offset;   <span class="comment">// 0 ue(v)</span></span><br><span class="line">        frame_crop_right_offset;  <span class="comment">// 0 ue(v)</span></span><br><span class="line">        frame_crop_top_offset;    <span class="comment">// 0 ue(v)</span></span><br><span class="line">        frame_crop_bottom_offset; <span class="comment">// 0 ue(v)</span></span><br><span class="line">    &#125;</span><br><span class="line">    vui_parameters_present_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (vui_parameters_present_flag)</span><br><span class="line">        vui_parameters();        <span class="comment">// 0</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>vui_parameters结构如下，它在<a target="_blank" rel="noopener" href="https://gitee.com/sumumm/audio-and-video/raw/master/%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99/T-REC-H.264-202408-I-E.pdf">ITU-T Rec. H.264 (08&#x2F;2024) Advanced video coding for generic audiovisual services</a>的E.1.1 VUI parameters syntax：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br></pre></td><td class="code"><pre><span class="line">vui_parameters()</span><br><span class="line">&#123;</span><br><span class="line">    aspect_ratio_info_present_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (aspect_ratio_info_present_flag)</span><br><span class="line">    &#123;</span><br><span class="line">        aspect_ratio_idc; <span class="comment">// 0 u(8)</span></span><br><span class="line">        <span class="keyword">if</span> (aspect_ratio_idc == Extended_SAR)</span><br><span class="line">        &#123;</span><br><span class="line">            sar_width;  <span class="comment">// 0 u(16)</span></span><br><span class="line">            sar_height; <span class="comment">// 0 u(16)</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    overscan_info_present_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (overscan_info_present_flag)</span><br><span class="line">        overscan_appropriate_flag;  <span class="comment">// 0 u(1)</span></span><br><span class="line">    video_signal_type_present_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (video_signal_type_present_flag)</span><br><span class="line">    &#123;</span><br><span class="line">        video_format;                    <span class="comment">// 0 u(3)</span></span><br><span class="line">        video_full_range_flag;           <span class="comment">// 0 u(1)</span></span><br><span class="line">        colour_description_present_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">        <span class="keyword">if</span> (colour_description_present_flag)</span><br><span class="line">        &#123;</span><br><span class="line">            colour_primaries;         <span class="comment">// 0 u(8)</span></span><br><span class="line">            transfer_characteristics; <span class="comment">// 0 u(8)</span></span><br><span class="line">            matrix_coefficients;      <span class="comment">// 0 u(8)</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    chroma_loc_info_present_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (chroma_loc_info_present_flag)</span><br><span class="line">    &#123;</span><br><span class="line">        chroma_sample_loc_type_top_field;    <span class="comment">// 0 ue(v)</span></span><br><span class="line">        chroma_sample_loc_type_bottom_field; <span class="comment">// 0 ue(v)</span></span><br><span class="line">    &#125;</span><br><span class="line">    timing_info_present_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (timing_info_present_flag)</span><br><span class="line">    &#123;</span><br><span class="line">        num_units_in_tick;     <span class="comment">// 0 u(32)</span></span><br><span class="line">        time_scale;            <span class="comment">// 0 u(32)</span></span><br><span class="line">        fixed_frame_rate_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    &#125;</span><br><span class="line">    nal_hrd_parameters_present_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (nal_hrd_parameters_present_flag)</span><br><span class="line">        hrd_parameters()                     <span class="comment">// 0</span></span><br><span class="line">    vcl_hrd_parameters_present_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (vcl_hrd_parameters_present_flag)</span><br><span class="line">        hrd_parameters() <span class="comment">// 0</span></span><br><span class="line">    <span class="keyword">if</span> (nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag)</span><br><span class="line">        low_delay_hrd_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    pic_struct_present_flag;        <span class="comment">// 0 u(1)</span></span><br><span class="line">    bitstream_restriction_flag;     <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (bitstream_restriction_flag)</span><br><span class="line">    &#123;</span><br><span class="line">        motion_vectors_over_pic_boundaries_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">        max_bytes_per_pic_denom;                 <span class="comment">// 0 ue(v)</span></span><br><span class="line">        max_bits_per_mb_denom;                   <span class="comment">// 0 ue(v)</span></span><br><span class="line">        log2_max_mv_length_horizontal;           <span class="comment">// 0 ue(v)</span></span><br><span class="line">        log2_max_mv_length_vertical;             <span class="comment">// 0 ue(v)</span></span><br><span class="line">        max_num_reorder_frames;                  <span class="comment">// 0 ue(v)</span></span><br><span class="line">        max_dec_frame_buffering;                 <span class="comment">// 0 ue(v)</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h1 id="二、SPS格式分析"><a href="#二、SPS格式分析" class="headerlink" title="二、SPS格式分析"></a><font size=3>二、SPS格式分析</font></h1><h2 id="1-ue-v-与se-v"><a href="#1-ue-v-与se-v" class="headerlink" title="1.ue(v)与se(v)"></a><font size=3>1.ue(v)与se(v)</font></h2><p>可以看到在 <a target="_blank" rel="noopener" href="https://gitee.com/sumumm/audio-and-video/raw/master/%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99/T-REC-H.264-202408-I-E.pdf">ITU-T Rec. H.264 (08&#x2F;2024) Advanced video coding for generic audiovisual services</a> 文档的7.3.2.1.1 Sequence parameter set data syntax 这里有说明每个成员是什么格式，例如：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241213164505373.png" alt="image-20241213164505373"  />

<p>u(1)、u(8)这些里面是数字的表示这个成员占了多少位，1就是1位，8就是8位。但是还有一些ue(v)、se(v)，这些是什么？</p>
<ul>
<li><code>ue(v)</code> 是一种用于编码和解码语法元素的编码方式，称为“无符号指数哥伦布编码”（Exponential-Golomb Coding）。这种编码方式主要用于表示非负整数，广泛应用于H.264的语法元素中，如宏块类型、运动矢量差值等。</li>
<li><code>se(v)</code> 是一种用于编码和解码有符号整数的编码方式，称为“有符号指数哥伦布编码”（Signed Exponential-Golomb Coding）。这种编码方式主要用于表示有符号整数，广泛应用于H.264的语法元素中，如运动矢量差值等。</li>
</ul>
<blockquote>
<p>Tips：</p>
<p>具体编解码的原理可以看这里后面指数哥伦布编码的相关笔记。</p>
</blockquote>
<h2 id="2-格式说明"><a href="#2-格式说明" class="headerlink" title="2. 格式说明"></a><font size=3>2. 格式说明</font></h2><h3 id="2-1-profile-idc"><a href="#2-1-profile-idc" class="headerlink" title="2.1 profile_idc"></a><font size=3>2.1 profile_idc</font></h3><p>标识当前H.264码流的profile。H.264中定义了四种常用的档次profile：</p>
<ul>
<li><p>Baseline：（最低Profile）级别支持I&#x2F;P 帧，只支持无交错（Progressive）和CAVLC，一般用于低阶或需要额外容错的应用，比如视频通话、手机视频等；</p>
</li>
<li><p>Extended：EP-Extended profile：进阶画质，是后来才加入的。支持I&#x2F;P&#x2F;B&#x2F;SP&#x2F;SI 帧，只支持无交错（Progressive）和CAVLC</p>
</li>
<li><p>Main：（主要Profile）级别提供I&#x2F;P&#x2F;B 帧，支持无交错（Progressive）和交错（Interlaced），同样提供对于CAVLC 和CABAC 的支持，用于主流消费类电子产品规格如低解码（相对而言）的mp4、便携的视频播放器、PSP和Ipod等；</p>
</li>
<li><p>High：（高端Profile，也叫FRExt）级别在Main的基础上增加了8x8 内部预测、自定义量化、无损视频编码和更多的YUV 格式（如4：4：4），用于广播及视频碟片存储（蓝光影片），高清电视的应用。</p>
</li>
</ul>
<p>在H.264的SPS中，第一个字节表示profile_idc，根据profile_idc的值可以确定码流符合哪一种档次。判断规律为：</p>
<figure class="highlight txt"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">profile_idc = 66 —— baseline profile;</span><br><span class="line">profile_idc = 77 —— main profile;</span><br><span class="line">profile_idc = 88 —— extended profile;</span><br><span class="line">profile_idc = 100 —— high</span><br></pre></td></tr></table></figure>

<p>在新版的标准中，还包括了High、High 10、High 4:2:2、High 4:4:4、High 10 Intra、High 4:2:2 Intra、High 4:4:4 Intra、CAVLC 4:4:4 Intra等，每一种都由不同的profile_idc表示。</p>
<h3 id="2-2-constraint-set0-5-flag"><a href="#2-2-constraint-set0-5-flag" class="headerlink" title="2.2 constraint_set0~5_flag"></a><font size=3>2.2 constraint_set0~5_flag</font></h3><p>constraint_set0_flag ~ constraint_set5_flag是在编码的档次方面对码流增加的其他一些额外限制性条件。具体参考h264标准文档（可以看这个<a target="_blank" rel="noopener" href="https://gitee.com/sumumm/audio-and-video/raw/master/%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99/T-REC-H.264-202408-I-E.pdf">ITU-T Rec. H.264 (08&#x2F;2024) Advanced video coding for generic audiovisual services</a> ），在附录A中列出了各种profile对应的情况。</p>
<h3 id="2-3-reserved-zero-2bits"><a href="#2-3-reserved-zero-2bits" class="headerlink" title="2.3 reserved_zero_2bits"></a><font size=3>2.3 reserved_zero_2bits</font></h3><p>保留位，始终等于0.</p>
<h3 id="2-4-level-idc"><a href="#2-4-level-idc" class="headerlink" title="2.4 level_idc"></a><font size=3>2.4 level_idc</font></h3><p>标识当前码流的Level。编码的Level定义了某种条件下的最大视频分辨率、最大视频帧率等参数，码流所遵从的level由level_idc指定。</p>
<h3 id="2-5-seq-parameter-set-id"><a href="#2-5-seq-parameter-set-id" class="headerlink" title="2.5 seq_parameter_set_id"></a><font size=3>2.5 seq_parameter_set_id</font></h3><p>表示当前的序列参数集的id。通过该id值，图像参数集pps可以引用其代表的sps中的参数。</p>
<h1 id="三、实例分析"><a href="#三、实例分析" class="headerlink" title="三、实例分析"></a><font size=3>三、实例分析</font></h1><p>这是我保存出来的一个SPS帧的信息：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">uint8_t</span> data_buffer[SPS_DATA_SIZE] = &#123;<span class="number">0x00</span>,<span class="number">0x00</span>,<span class="number">0x00</span>,<span class="number">0x01</span>,<span class="number">0x67</span>,<span class="number">0x64</span>,<span class="number">0x00</span>,<span class="number">0x33</span>,<span class="number">0xac</span>,<span class="number">0x15</span>,<span class="number">0x14</span>,<span class="number">0xa0</span>,<span class="number">0x50</span>,<span class="number">0x05</span>,<span class="number">0xba</span>,<span class="number">0x68</span>,<span class="number">0x80</span>,<span class="number">0x00</span>,<span class="number">0x01</span>,<span class="number">0xf4</span>,<span class="number">0x00</span>,<span class="number">0x00</span>,<span class="number">0x75</span>,<span class="number">0x30</span>,<span class="number">0x02</span> &#125;;</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216150048551.png" alt="image-20241216150048551"  />

<p>现在就来分析一下。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216202528199.png" alt="image-20241216202528199"  />

<h2 id="1-0x00-0x00-0x00-0x01"><a href="#1-0x00-0x00-0x00-0x01" class="headerlink" title="1. 0x00,0x00,0x00,0x01"></a><font size=3>1. 0x00,0x00,0x00,0x01</font></h2><img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216150702583.png" alt="image-20241216150702583"  />

<p>这4个字节是start code，就是起始码，表示这是一个NALU的开始。</p>
<h2 id="2-0x67"><a href="#2-0x67" class="headerlink" title="2. 0x67"></a><font size=3>2. 0x67</font></h2><img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216150721839.png" alt="image-20241216150721839"  />

<p>这个字节是nalutype，它与上0x1f就是7，表示这是一个SPS。</p>
<h2 id="3-第5、6、7字节"><a href="#3-第5、6、7字节" class="headerlink" title="3. 第5、6、7字节"></a><font size=3>3. 第5、6、7字节</font></h2><p>接下来就是SPS帧的相关信息了，先来分析第一个哥伦布编码前的这三个字节：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">seq_parameter_set_data()</span><br><span class="line">&#123;</span><br><span class="line">    profile_idc;                          <span class="comment">// 0 u(8)</span></span><br><span class="line">    constraint_set0_flag;                 <span class="comment">// 0 u(1)</span></span><br><span class="line">    constraint_set1_flag;                 <span class="comment">// 0 u(1)</span></span><br><span class="line">    constraint_set2_flag;                 <span class="comment">// 0 u(1)</span></span><br><span class="line">    constraint_set3_flag;                 <span class="comment">// 0 u(1)</span></span><br><span class="line">    constraint_set4_flag;                 <span class="comment">// 0 u(1)</span></span><br><span class="line">    constraint_set5_flag;                 <span class="comment">// 0 u(1)</span></span><br><span class="line">    reserved_zero_2bits; <span class="comment">/* equal to 0 */</span> <span class="comment">// 0 u(2)</span></span><br><span class="line">    level_idc;                            <span class="comment">// 0 u(8)</span></span><br><span class="line">	<span class="comment">//......</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>对应到上面的数据就是：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216203352731.png" alt="image-20241216203352731"  />

<p>可以得到：</p>
<figure class="highlight txt"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">64          : profile_idc=0x64(100 —— high profile)</span><br><span class="line">00 33       : level_idc=0x33(51)</span><br></pre></td></tr></table></figure>

<h2 id="4-第8字节"><a href="#4-第8字节" class="headerlink" title="4. 第8字节"></a><font size=3>4. 第8字节</font></h2><p>接下来分析ue(v)这个seq_parameter_set_id，由于前面profile_idc&#x3D;100，所以这里if循环里面的也会有。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line">seq_parameter_set_data()</span><br><span class="line">&#123;</span><br><span class="line">	<span class="comment">//......</span></span><br><span class="line">    seq_parameter_set_id;                 <span class="comment">// 0 ue(v)</span></span><br><span class="line">    <span class="keyword">if</span> (profile_idc == <span class="number">100</span> || profile_idc == <span class="number">110</span> || </span><br><span class="line">        profile_idc == <span class="number">122</span> || profile_idc == <span class="number">244</span> || </span><br><span class="line">        profile_idc == <span class="number">44</span> || profile_idc == <span class="number">83</span> || </span><br><span class="line">        profile_idc == <span class="number">86</span> || profile_idc == <span class="number">118</span> || </span><br><span class="line">        profile_idc == <span class="number">128</span> || profile_idc == <span class="number">138</span> || </span><br><span class="line">        profile_idc == <span class="number">139</span> || profile_idc == <span class="number">134</span> || </span><br><span class="line">        profile_idc == <span class="number">135</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        chroma_format_idc;                    <span class="comment">// 0 ue(v)</span></span><br><span class="line">            <span class="keyword">if</span> (chroma_format_idc = = <span class="number">3</span>)</span><br><span class="line">                separate_colour_plane_flag;   <span class="comment">// 0 u(1)</span></span><br><span class="line">        bit_depth_luma_minus8;                <span class="comment">// 0 ue(v)</span></span><br><span class="line">        bit_depth_chroma_minus8;              <span class="comment">// 0 ue(v)</span></span><br><span class="line">        qpprime_y_zero_transform_bypass_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">        seq_scaling_matrix_present_flag;      <span class="comment">// 0 u(1)</span></span><br><span class="line">        <span class="keyword">if</span> (seq_scaling_matrix_present_flag)</span><br><span class="line">            <span class="keyword">for</span> (i = <span class="number">0</span>; i &lt; ((chroma_format_idc != <span class="number">3</span>) ? <span class="number">8</span> : <span class="number">12</span>); i++)</span><br><span class="line">            &#123;</span><br><span class="line">                seq_scaling_list_present_flag[i]; <span class="comment">// 0 u(1)</span></span><br><span class="line">                <span class="keyword">if</span> (seq_scaling_list_present_flag[i])</span><br><span class="line">                    <span class="keyword">if</span> (i &lt; <span class="number">6</span>)</span><br><span class="line">                        scaling_list(ScalingList4x4[i], <span class="number">16</span>, </span><br><span class="line">                            UseDefaultScalingMatrix4x4Flag[i]);     <span class="comment">// 0</span></span><br><span class="line">                    <span class="keyword">else</span></span><br><span class="line">                        scaling_list(ScalingList8x8[i - <span class="number">6</span>], <span class="number">64</span>, </span><br><span class="line">                            UseDefaultScalingMatrix8x8Flag[i - <span class="number">6</span>]); <span class="comment">// 0</span></span><br><span class="line">            &#125;</span><br><span class="line">    &#125;</span><br><span class="line">	<span class="comment">//......</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>由于哥伦布编码要解出来后才知道数据有多长，所以先看0xac这个字节：</p>
<figure class="highlight txt"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ac : 1010 1100</span><br></pre></td></tr></table></figure>

<p>（1）先看第一位，如下图：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216203927607.png" alt="image-20241216203927607"  />

<p>根据哥伦布编码的原理，第一个bit是1，前面没有0，所以这里不需要向后读取，这里就是2^0-1+0&#x3D;0，所以seq_parameter_set_id&#x3D;0。</p>
<p>（2）profile_idc&#x3D;100，所以if成立。再看后面1位：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216203958920.png" alt="image-20241216203958920"  />

<p>接下来分析if里面的chroma_format_idc，他也是一个ue(v)类型，继续向后分析看0的个数，如上图所示，这里有1个0，所以从1向后读1位，就是<code>0</code>，所以这里就是2^1-1+0&#x3D;1，即chroma_format_idc&#x3D;1。</p>
<p>（3）继续往后分析的起始位置如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204059314.png" alt="image-20241216204059314"  />

<p>由于chroma_format_idc不等于3，这里我们继续往后分析bit_depth_luma_minus8，继续向后找发现是一个1，如上图所示，所以这里bit_depth_luma_minus8&#x3D;0.</p>
<p>（4）如下图：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204144271.png" alt="image-20241216204144271"  />

<p>再后面是 bit_depth_chroma_minus8，也是一个ue(v)数据，所以继续分析，如上图所示，后面是一个1，所以这里 bit_depth_chroma_minus8 也是0。分析到这里，0xac这个字节还剩下2位。</p>
<p>（5）如下图</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204221277.png" alt="image-20241216204221277"  />

<p>继续往下是 qpprime_y_zero_transform_bypass_flag，它是个u(1)，占1位，如上图，在这里就是0。</p>
<p>（6）如下图</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204303087.png" alt="image-20241216204303087"  />

<p>再往下是seq_scaling_matrix_present_flag，这也是一个u(1)，如上图，这里就是0了。所以后面的if不成立，这一段就分析结束了。到这里为止，分析了一个完整的字节0xac。</p>
<p>（7）最终结果：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204439678.png" alt="image-20241216204439678"  />

<p>最后这个0xac字节刚好分析完，指针指向下一个数据的第一位。</p>
<h2 id="5-第9字节"><a href="#5-第9字节" class="headerlink" title="5. 第9字节"></a><font size=3>5. 第9字节</font></h2><p>接下来是log2_max_frame_num_minus4后面这部分，发现连续两个都是ue(v)，这里只能解码后才知道长度了。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">seq_parameter_set_data()</span><br><span class="line">&#123;</span><br><span class="line">	<span class="comment">//......</span></span><br><span class="line">    log2_max_frame_num_minus4; <span class="comment">// 0 ue(v)</span></span><br><span class="line">    pic_order_cnt_type;        <span class="comment">// 0 ue(v)</span></span><br><span class="line">    <span class="keyword">if</span> (pic_order_cnt_type == <span class="number">0</span>)</span><br><span class="line">        log2_max_pic_order_cnt_lsb_minus4; <span class="comment">// 0 ue(v)</span></span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">if</span> (pic_order_cnt_type == <span class="number">1</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        delta_pic_order_always_zero_flag;      <span class="comment">// 0 u(1)</span></span><br><span class="line">        offset_for_non_ref_pic;                <span class="comment">// 0 se(v)</span></span><br><span class="line">        offset_for_top_to_bottom_field;        <span class="comment">// 0 se(v)</span></span><br><span class="line">        num_ref_frames_in_pic_order_cnt_cycle; <span class="comment">// 0 ue(v)</span></span><br><span class="line">        <span class="keyword">for</span> (i = <span class="number">0</span>; i &lt; num_ref_frames_in_pic_order_cnt_cycle; i++)</span><br><span class="line">            offset_for_ref_frame[i];      <span class="comment">// 0 use(v)</span></span><br><span class="line">    &#125;</span><br><span class="line">	<span class="comment">//......</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>先看0x15这个数据：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204439678.png" alt="image-20241216204439678"  />

<figure class="highlight txt"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">15 : 0001 0101</span><br></pre></td></tr></table></figure>

<p>（1）如下图位置：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204439678.png" alt="image-20241216204439678"  />

<p>这里是3个0，所以要从1后面读3个位，就是<code>010</code>，这里就是2^3-1+2&#x3D;9。所以 log2_max_frame_num_minus4 &#x3D; 9。</p>
<p>（2）上面读取完毕，0x15这个字节还剩余1位，如下图：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204923372.png" alt="image-20241216204923372"  />

<p>（3）最终结果：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204923372.png" alt="image-20241216204923372"  />

<p>分析到这里，0x15这个字节还剩余1位。</p>
<h2 id="6-第9-10字节"><a href="#6-第9-10字节" class="headerlink" title="6. 第9 - 10字节"></a><font size=3>6. 第9 - 10字节</font></h2><p>接下来是pic_order_cnt_type后面这部分，发现pic_order_cnt_type是ue(v)：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">seq_parameter_set_data()</span><br><span class="line">&#123;</span><br><span class="line">	<span class="comment">//......</span></span><br><span class="line">    pic_order_cnt_type;        <span class="comment">// 0 ue(v)</span></span><br><span class="line">    <span class="keyword">if</span> (pic_order_cnt_type == <span class="number">0</span>)</span><br><span class="line">        log2_max_pic_order_cnt_lsb_minus4; <span class="comment">// 0 ue(v)</span></span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">if</span> (pic_order_cnt_type == <span class="number">1</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        delta_pic_order_always_zero_flag;      <span class="comment">// 0 u(1)</span></span><br><span class="line">        offset_for_non_ref_pic;                <span class="comment">// 0 se(v)</span></span><br><span class="line">        offset_for_top_to_bottom_field;        <span class="comment">// 0 se(v)</span></span><br><span class="line">        num_ref_frames_in_pic_order_cnt_cycle; <span class="comment">// 0 ue(v)</span></span><br><span class="line">        <span class="keyword">for</span> (i = <span class="number">0</span>; i &lt; num_ref_frames_in_pic_order_cnt_cycle; i++)</span><br><span class="line">            offset_for_ref_frame[i];      <span class="comment">// 0 use(v)</span></span><br><span class="line">    &#125;</span><br><span class="line">	<span class="comment">//......</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>前面一个字节分析完还剩余1位，加上0x14，数据情况如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204923372.png" alt="image-20241216204923372"  />

<figure class="highlight txt"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">15 :         1</span><br><span class="line">14 : 0001 0100</span><br></pre></td></tr></table></figure>

<p>（1）如下图：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216204923372.png" alt="image-20241216204923372"  />

<p>往后的pic_order_cnt_type是一个ue(v)类型，我们继续找0，会发现这里只有一个1，所以这里pic_order_cnt_type &#x3D; 2^0-1+0&#x3D;0。到此0x15这个数据分析完毕。后面该下一个字节的第一位。</p>
<p>（2）如下图，上面0x15字节全部分析完毕，从0x14的第一个字节开始：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216205138883.png" alt="image-20241216205138883"  />

<p>由于上面的pic_order_cnt_type&#x3D;0，这里log2_max_pic_order_cnt_lsb_minus4存在，它是一个ue(v)类型，我们开始从0x14的第一位分析，这里有3个0，所以向后读3位<code>010</code>，这里就是2^3-1+2&#x3D;9。所以 log2_max_pic_order_cnt_lsb_minus4 &#x3D; 9。</p>
<p>（3）最终结果</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216205232610.png" alt="image-20241216205232610"  />

<p>这一段就分析到这里，还剩下1个位。</p>
<h2 id="7-第11-14字节"><a href="#7-第11-14字节" class="headerlink" title="7. 第11 - 14字节"></a><font size=3>7. 第11 - 14字节</font></h2><p>接下来继续往下，下面这个四个不涉及if之类的，放在一起分析</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">seq_parameter_set_data()</span><br><span class="line">&#123;</span><br><span class="line">	<span class="comment">//......</span></span><br><span class="line">    max_num_ref_frames;                   <span class="comment">// 0 ue(v)</span></span><br><span class="line">    gaps_in_frame_num_value_allowed_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    pic_width_in_mbs_minus1;              <span class="comment">// 0 ue(v)</span></span><br><span class="line">    pic_height_in_map_units_minus1;       <span class="comment">// 0 ue(v)</span></span><br><span class="line">	<span class="comment">//......</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>前面分析完0x14，还剩余1位，再继续看下面的0xa0（其实这里有预留了，因为后面会发现，这几个成员并不是一个字节就能容纳的）：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216205232610.png" alt="image-20241216205232610"  />

<figure class="highlight txt"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">14 :         0</span><br><span class="line">a0 : 1010 0000</span><br><span class="line">50 : 0101 0000</span><br><span class="line">05 : 0000 0101</span><br></pre></td></tr></table></figure>

<p>（1）先看这个max_num_ref_frames，是一个ue(v)类型，我们还是按指数哥伦布编码解如下图：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216205232610.png" alt="image-20241216205232610"  />

<p>发现有1个0，这里向后读1位，这里就是2^1-1+0&#x3D;1。所以max_num_ref_frames&#x3D;1。</p>
<p>（2）继续向后看gaps_in_frame_num_value_allowed_flag，如下图：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216205356440.png" alt="image-20241216205356440"  />

<p>gaps_in_frame_num_value_allowed_flag是个u(1)类型，只占1位，所以它的值为1。</p>
<p>（3）再来看pic_width_in_mbs_minus1，如下图：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241216205425465.png" alt="image-20241216205425465"  />

<p>这个pic_width_in_mbs_minus1是ue(v)类型，所以要向后找0的个数，发现0xa0剩余几位全为0，所以要读到下一个字节0x50，这里向后一共是6个0，所以向后数6位<code>010 000</code>，也就是16（注意这里是二进制的<code>10000</code>），这里就是2^6-1+16&#x3D;79。</p>
<p>（4）再来看pic_height_in_map_units_minus1的值：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217090353410.png" alt="image-20241217090353410"  />

<p>pic_height_in_map_units_minus1是一个ue(v)类型，这里就是5个0，往后读5位就是<code>01101</code>，就是13，这里就是2^5-1+13&#x3D;44。</p>
<p>（5）最终结果</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217090951614.png" alt="image-20241217090951614"  />

<p>最后第14个字节还剩余5位没有分析。</p>
<h2 id="8-第14字节"><a href="#8-第14字节" class="headerlink" title="8. 第14字节"></a><font size=3>8. 第14字节</font></h2><p>继续往下分析这一部分：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">seq_parameter_set_data()</span><br><span class="line">&#123;</span><br><span class="line">    <span class="comment">//......</span></span><br><span class="line">    frame_mbs_only_flag;                  <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (!frame_mbs_only_flag)</span><br><span class="line">        mb_adaptive_frame_field_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    direct_8x8_inference_flag;        <span class="comment">// 0 u(1)</span></span><br><span class="line">    frame_cropping_flag;              <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (frame_cropping_flag)</span><br><span class="line">    &#123;</span><br><span class="line">        frame_crop_left_offset;   <span class="comment">// 0 ue(v)</span></span><br><span class="line">        frame_crop_right_offset;  <span class="comment">// 0 ue(v)</span></span><br><span class="line">        frame_crop_top_offset;    <span class="comment">// 0 ue(v)</span></span><br><span class="line">        frame_crop_bottom_offset; <span class="comment">// 0 ue(v)</span></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//......</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>之前分析完后，数据剩余情况如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217090951614.png" alt="image-20241217090951614"  />

<p>（1）frame_mbs_only_flag是一个u(1)类型，只占1位：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217090951614.png" alt="image-20241217090951614"  />

<p>这里就是1，所以frame_mbs_only_flag&#x3D;1，后面的if不成立。</p>
<p>（2）direct_8x8_inference_flag是一个u(1)类型：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217091336803.png" alt="image-20241217091336803"  />

<p>读取1位就是1，所以direct_8x8_inference_flag&#x3D;1。</p>
<p>（3）frame_cropping_flag是一个u(1)类型，只占1位，如下图：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217091442769.png" alt="image-20241217091442769"  />

<p>所以frame_cropping_flag&#x3D;0。这样的话后面的if不成立。这一段就分析完毕了。</p>
<p>（4）最终结果</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217091557561.png" alt="image-20241217091557561"  />

<p>上面分析完数据情况如上图。</p>
<h2 id="9-第14字节"><a href="#9-第14字节" class="headerlink" title="9. 第14字节"></a><font size=3>9. 第14字节</font></h2><p>接下来分析最后一部分：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">seq_parameter_set_data()</span><br><span class="line">&#123;</span><br><span class="line">	<span class="comment">//......</span></span><br><span class="line">    vui_parameters_present_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (vui_parameters_present_flag)</span><br><span class="line">        vui_parameters();        <span class="comment">// 0</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>上面分析完的数据情况如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217091557561.png" alt="image-20241217091557561"  />

<p>（1）vui_parameters_present_flag是一个u(1)类型，只需要读取1位：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217091557561.png" alt="image-20241217091557561"  />

<p>所以有vui_parameters_present_flag&#x3D;1。后面的if成立。</p>
<p>（2）由于后面是另一个结构，分析到这里结束，最后数据情况如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217092002476.png" alt="image-20241217092002476"  />

<h2 id="10-第14-15字节"><a href="#10-第14-15字节" class="headerlink" title="10. 第14 - 15字节"></a><font size=3>10. 第14 - 15字节</font></h2><p>接下来就是vui_parameters()里面的内容了，先来分析这一部分：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">vui_parameters()</span><br><span class="line">&#123;</span><br><span class="line">    aspect_ratio_info_present_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (aspect_ratio_info_present_flag)</span><br><span class="line">    &#123;</span><br><span class="line">        aspect_ratio_idc; <span class="comment">// 0 u(8)</span></span><br><span class="line">        <span class="keyword">if</span> (aspect_ratio_idc == Extended_SAR)</span><br><span class="line">        &#123;</span><br><span class="line">            sar_width;  <span class="comment">// 0 u(16)</span></span><br><span class="line">            sar_height; <span class="comment">// 0 u(16)</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    overscan_info_present_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (overscan_info_present_flag)</span><br><span class="line">        overscan_appropriate_flag;  <span class="comment">// 0 u(1)</span></span><br><span class="line">    video_signal_type_present_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (video_signal_type_present_flag)</span><br><span class="line">    &#123;</span><br><span class="line">        video_format;                    <span class="comment">// 0 u(3)</span></span><br><span class="line">        video_full_range_flag;           <span class="comment">// 0 u(1)</span></span><br><span class="line">        colour_description_present_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">        <span class="keyword">if</span> (colour_description_present_flag)</span><br><span class="line">        &#123;</span><br><span class="line">            colour_primaries;         <span class="comment">// 0 u(8)</span></span><br><span class="line">            transfer_characteristics; <span class="comment">// 0 u(8)</span></span><br><span class="line">            matrix_coefficients;      <span class="comment">// 0 u(8)</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//......</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>前面执行完毕数据情况如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217092002476.png" alt="image-20241217092002476"  />

<p>第14字节还剩余1位。</p>
<p>（1）aspect_ratio_info_present_flag是u(1)类型，读取1位：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217092002476.png" alt="image-20241217092002476"  />

<p>所以aspect_ratio_info_present_flag&#x3D;0。所以后面的if不成立。到这里第14字节就分析完毕了。</p>
<p>（2）再来分析overscan_info_present_flag，它是u(1)类型：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217092820786.png" alt="image-20241217092820786"  />

<p>读取1位就是overscan_info_present_flag&#x3D;0。所以它后面的if也不成立。</p>
<p>（3）继续看video_signal_type_present_flag，它是u(1)类型：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217093104751.png" alt="image-20241217093104751"  />

<p>读取1位就是video_signal_type_present_flag&#x3D;1，所以后面的if成立。</p>
<p>（4）接下来分析if (video_signal_type_present_flag)中的内容：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217093207793.png" alt="image-20241217093207793"  />

<p>video_format是u(3)，往后读3位是101，所以video_format&#x3D;5。video_full_range_flag是u(1)，往后再读1位就是0，所以video_full_range_flag&#x3D;0。后面是colour_description_present_flag，也是u(1)，继续读1位就是0，所以colour_description_present_flag&#x3D;0。后面的if不成立。这里一共分析了5个位。</p>
<p>（5）最终结果</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217093607508.png" alt="image-20241217093607508"  />

<p>上面分析完，数据如上图。</p>
<h2 id="11-第15-24字节"><a href="#11-第15-24字节" class="headerlink" title="11. 第15 - 24字节"></a><font size=3>11. 第15 - 24字节</font></h2><p>继续往下看后面的这部分：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">vui_parameters()</span><br><span class="line">&#123;</span><br><span class="line">	<span class="comment">//......</span></span><br><span class="line">    chroma_loc_info_present_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (chroma_loc_info_present_flag)</span><br><span class="line">    &#123;</span><br><span class="line">        chroma_sample_loc_type_top_field;    <span class="comment">// 0 ue(v)</span></span><br><span class="line">        chroma_sample_loc_type_bottom_field; <span class="comment">// 0 ue(v)</span></span><br><span class="line">    &#125;</span><br><span class="line">    timing_info_present_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (timing_info_present_flag)</span><br><span class="line">    &#123;</span><br><span class="line">        num_units_in_tick;     <span class="comment">// 0 u(32)</span></span><br><span class="line">        time_scale;            <span class="comment">// 0 u(32)</span></span><br><span class="line">        fixed_frame_rate_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    &#125;</span><br><span class="line">	<span class="comment">//......</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>前面分析完数据情况如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217093607508.png" alt="image-20241217093607508"  />

<p>（1）chroma_loc_info_present_flag是u(1)类型，读取1位：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217093607508.png" alt="image-20241217093607508"  />

<p>有chroma_loc_info_present_flag&#x3D;0，所以后面的if不成立。到这里第15字节分析完毕。</p>
<p>（2）timing_info_present_flag是u(1)，继续读取1位：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217093845893.png" alt="image-20241217093845893"  />

<p>有timing_info_present_flag&#x3D;1。所以if (timing_info_present_flag)成立。</p>
<p>（3）if (timing_info_present_flag)中是两个u(32)，一个u(1)：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217094157229.png" alt="image-20241217094157229"  />

<p>所以有num_units_in_tick&#x3D;11 1110 1000，也就是1000，所以num_units_in_tick&#x3D;1000。time_scale&#x3D;1110 1010 0110 0000&#x3D;60000。fixed_frame_rate_flag&#x3D;0。</p>
<p>（4）最终结果</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217095023307.png" alt="image-20241217095023307"  />

<p>上面分析完，就到了最后一个字节，最后还剩余6位。</p>
<h2 id="12-第25字节"><a href="#12-第25字节" class="headerlink" title="12. 第25字节"></a><font size=3>12. 第25字节</font></h2><p>再来看最后这一部分：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">vui_parameters()</span><br><span class="line">&#123;</span><br><span class="line">	<span class="comment">//......</span></span><br><span class="line">    nal_hrd_parameters_present_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (nal_hrd_parameters_present_flag)</span><br><span class="line">        hrd_parameters()                     <span class="comment">// 0</span></span><br><span class="line">    vcl_hrd_parameters_present_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (vcl_hrd_parameters_present_flag)</span><br><span class="line">        hrd_parameters() <span class="comment">// 0</span></span><br><span class="line">    <span class="keyword">if</span> (nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag)</span><br><span class="line">		low_delay_hrd_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">    pic_struct_present_flag;        <span class="comment">// 0 u(1)</span></span><br><span class="line">    bitstream_restriction_flag;     <span class="comment">// 0 u(1)</span></span><br><span class="line">    <span class="keyword">if</span> (bitstream_restriction_flag)</span><br><span class="line">    &#123;</span><br><span class="line">        motion_vectors_over_pic_boundaries_flag; <span class="comment">// 0 u(1)</span></span><br><span class="line">        max_bytes_per_pic_denom;                 <span class="comment">// 0 ue(v)</span></span><br><span class="line">        max_bits_per_mb_denom;                   <span class="comment">// 0 ue(v)</span></span><br><span class="line">        log2_max_mv_length_horizontal;           <span class="comment">// 0 ue(v)</span></span><br><span class="line">        log2_max_mv_length_vertical;             <span class="comment">// 0 ue(v)</span></span><br><span class="line">        max_num_reorder_frames;                  <span class="comment">// 0 ue(v)</span></span><br><span class="line">        max_dec_frame_buffering;                 <span class="comment">// 0 ue(v)</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>前面分析完后，数据剩余情况如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217095023307.png" alt="image-20241217095023307"  />

<p>（1）nal_hrd_parameters_present_flag占1位：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217095023307.png" alt="image-20241217095023307"  />

<p>所以nal_hrd_parameters_present_flag&#x3D;0，后面的if (nal_hrd_parameters_present_flag)不成立。</p>
<p>（2）vcl_hrd_parameters_present_flag占1位：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217101222645.png" alt="image-20241217101222645"  />

<p>所以vcl_hrd_parameters_present_flag&#x3D;0，后面的if (vcl_hrd_parameters_present_flag)不成立。</p>
<p>（3）由于 nal_hrd_parameters_present_flag 和 vcl_hrd_parameters_present_flag 都是0，所以if  (nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag) 不成立。</p>
<p>（4）pic_struct_present_flag占1位：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217101419996.png" alt="image-20241217101419996"  />

<p>pic_struct_present_flag&#x3D;0。</p>
<p>（5）bitstream_restriction_flag占1位：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217101535747.png" alt="image-20241217101535747"  />

<p>bitstream_restriction_flag&#x3D;0。所以后面的if (bitstream_restriction_flag)不成立。</p>
<h2 id="13-总结"><a href="#13-总结" class="headerlink" title="13. 总结"></a><font size=3>13. 总结</font></h2><img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/LV05-02-H264-11-01-SPS%E5%B8%A7%E7%AE%80%E4%BB%8B/img/image-20241217101721321.png" alt="image-20241217101721321"  />

<p>最后数据还剩余2位。其他关键信息已经全部解析完毕。</p>

    </div>

    
    
    

    <footer class="post-footer">




    <div>
        
            <div style="text-align:center;color: #ccc;font-size:14px;">
            ----------本文结束
            <i class="fas fa-fan fa-spin" style="color: #FF1493; font-size: 1rem"></i>
            感谢您的阅读----------
            </div>
        
    </div>





  
  <div class="my_post_copyright"> 
    <p><span>文章标题:</span><a href="/post/8213b8b3.html">LV05-02-H264-11-01-SPS帧简介</a></p>
    <p><span>文章作者:</span><a href="/" title="欢迎访问 《苏木》 的学习笔记">苏木</a></p>
    <p><span>发布时间:</span>2024年12月17日 - 23:45</p>
    <p><span>最后更新:</span>2025年06月14日 - 00:25</p>
    <p><span>原始链接:</span><a href="/post/8213b8b3.html" title="LV05-02-H264-11-01-SPS帧简介">https://sumumm.github.io/post/8213b8b3.html</a></p>
    <p><span>许可协议:</span><i class="fab fa-creative-commons"></i> <a rel="license" href= "https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
  </div>
  


          <div class="post-tags">
              <a href="/tags/LV05-%E8%A7%86%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81/" rel="tag"><i class="fa fa-tag"></i> LV05-视频编解码</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/post/d1a18079.html" rel="prev" title="LV05-02-H264-11-02-SPS帧解析">
                  <i class="fa fa-angle-left"></i> LV05-02-H264-11-02-SPS帧解析
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/post/bc764bc5.html" rel="next" title="LV05-02-H264-10-H264的profile与level">
                  LV05-02-H264-10-H264的profile与level <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2017 – 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">苏木</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">3.7m</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">225:26</span>
  </span>
</div>




    <span id="sitetime"></span>
    <script defer language=javascript>
        function siteTime()
        {
            window.setTimeout("siteTime()", 1000);
            var seconds = 1000;
            var minutes = seconds * 60;
            var hours = minutes * 60;
            var days = hours * 24;
            var years = days * 365;
            var today = new Date();
            var todayYear = today.getFullYear();
            var todayMonth = today.getMonth()+1;
            var todayDate = today.getDate();
            var todayHour = today.getHours();
            var todayMinute = today.getMinutes();
            var todaySecond = today.getSeconds();
            /*==================================================
            Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
            year        - 作为date对象的年份，为4位年份值
            month       - 0-11之间的整数，做为date对象的月份
            day         - 1-31之间的整数，做为date对象的天数
            hours       - 0(午夜24点)-23之间的整数，做为date对象的小时数
            minutes     - 0-59之间的整数，做为date对象的分钟数
            seconds     - 0-59之间的整数，做为date对象的秒数
            microseconds - 0-999之间的整数，做为date对象的毫秒数
            ==================================================*/
            var t1 = Date.UTC(2017, 
                              5, 
                              19, 
                              0, 
                              0, 
                              0); //北京时间
            var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
            var diff = t2-t1;
            var diffYears = Math.floor(diff/years);
            var diffDays = Math.floor((diff/days)-diffYears*365);
            var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
            var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
            var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
            document.getElementById("sitetime").innerHTML="已在这里 "+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒";
        }
        siteTime();
    </script>



    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.umd.js" integrity="sha256-ytMJGN3toR+a84u7g7NuHm91VIR06Q41kMWDr2pq7Zo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>




  <script src="/js/third-party/fancybox.js"></script>

  <script src="/js/third-party/pace.js"></script>


  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


 
        <div id="click-show-text"
            data-mobile = false
            data-text = 富强,民主,文明,和谐,自由,平等,公正,法制,爱国,敬业,诚信,友善
            data-fontsize = 15px
            data-random= false>
        </div>
       

      
        <script async src=https://cdn.jsdelivr.net/npm/hexo-next-mouse-effect@latest/click/showText.js></script>
      

      
    




    <script async src="/js/fancybox_param.js"></script>





<!-- APlayer本体 -->



</body>
</html>
